package demo;

/**
 *  买卖股票的最佳时机
 */
class Solution13 {
	public int maxProfit(int[] prices) {
		int maxProfit = 0;
		int price = prices[0];
		for (int i = 0; i < prices.length; i++) {
			maxProfit = Math.max(maxProfit, prices[i] - price);
			price = Math.min(price, prices[i]);
		}
		return maxProfit;
	}
}

